<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>黄梅戏方言语言词典系统 - 用户注册</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body {
            background: url('images/loginbg2.jpg') no-repeat center center fixed;
            background-size: cover;
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Microsoft YaHei', sans-serif;
            padding: 20px;
        }

        .register-container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            padding: 40px;
            width: 100%;
            max-width: 500px;
            animation: fadeInUp 0.6s ease-out;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .register-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .register-header h2 {
            color: #333;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .register-header p {
            color: #666;
            font-size: 14px;
        }

        .form-floating {
            margin-bottom: 20px;
        }

        .form-control {
            border-radius: 10px;
            border: 2px solid #e9ecef;
            padding: 12px 15px;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
        }

        .btn-register {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            border-radius: 10px;
            padding: 12px;
            font-weight: 600;
            transition: all 0.3s ease;
            width: 100%;
            margin-top: 10px;
        }

        .btn-register:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-back {
            background: #6c757d;
            border: none;
            border-radius: 10px;
            padding: 12px;
            font-weight: 600;
            transition: all 0.3s ease;
            width: 100%;
        }

        .btn-back:hover {
            background: #5a6268;
            transform: translateY(-2px);
        }

        .input-group-text {
            background: #f8f9fa;
            border: 2px solid #e9ecef;
            border-right: none;
        }

        .alert {
            border-radius: 10px;
            border: none;
        }
    </style>
</head>
<body>
<div class="register-container">
    <div class="register-header">
        <h2><i class="bi bi-person-plus"></i> 用户注册</h2>
        <p>安庆地区方言正音电子词典平台</p>
    </div>

    <form name="f1" method="post" action="">
        <div class="form-floating">
            <input type="text" class="form-control" name="yonghuming" id="yonghuming" placeholder="用户名" required>
            <label for="yonghuming"><i class="bi bi-person"></i> 用户名</label>
        </div>

        <div class="form-floating">
            <input type="password" class="form-control" name="mima" id="mima" placeholder="密码" required>
            <label for="mima"><i class="bi bi-lock"></i> 密码</label>
        </div>

        <div class="form-floating">
            <input type="text" class="form-control" name="xingming" id="xingming" placeholder="姓名">
            <label for="xingming"><i class="bi bi-card-text"></i> 姓名</label>
        </div>

        <div class="form-floating">
            <select class="form-select" name="xingbie" id="xingbie">
                <option value="男">男</option>
                <option value="女">女</option>
            </select>
            <label for="xingbie"><i class="bi bi-gender-ambiguous"></i> 性别</label>
        </div>

        <div class="form-floating">
            <input type="text" class="form-control" name="lianxidianhua" id="lianxidianhua" placeholder="联系电话">
            <label for="lianxidianhua"><i class="bi bi-telephone"></i> 联系电话</label>
        </div>

        <div class="form-floating">
            <input type="text" class="form-control" name="shenfenzheng" id="shenfenzheng" placeholder="身份证">
            <label for="shenfenzheng"><i class="bi bi-credit-card"></i> 身份证</label>
        </div>

        <div class="form-floating">
            <input type="text" class="form-control" name="youxiang" id="youxiang" placeholder="邮箱">
            <label for="youxiang"><i class="bi bi-envelope"></i> 邮箱</label>
        </div>

        <div class="form-floating">
            <textarea class="form-control" name="beizhu" id="beizhu" placeholder="备注" style="height: 100px"></textarea>
            <label for="beizhu"><i class="bi bi-chat-square-text"></i> 备注</label>
        </div>

        <button type="submit" class="btn btn-primary btn-register" onclick="return check();">
            <i class="bi bi-check-circle"></i> 注册
        </button>

        <button type="button" class="btn btn-secondary btn-back" onclick="history.back();">
            <i class="bi bi-arrow-left"></i> 返回
        </button>
    </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script language="javascript">
function check() {
    if (document.f1.yonghuming.value == "") {
        alert("请输入用户名!");
        document.f1.yonghuming.focus();
        return false;
    }

    if (document.f1.mima.value == "") {
        alert("请输入密码!");
        document.f1.mima.focus();
        return false;
    }

    // 检查用户名是否已存在
    var yonghuming = document.f1.yonghuming.value;
    var xhr = new XMLHttpRequest();
    xhr.open("POST", "checkYonghuName.action", false); // 同步请求
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send("yonghuming=" + encodeURIComponent(yonghuming));

    if (xhr.responseText === "exists") {
        alert("用户名已存在，请选择其他用户名！");
        document.f1.yonghuming.focus();
        return false;
    }

    return true;
}
</script>
</body>
</html>